package com.dcms.admin.service.impl;

import com.dcms.admin.bean.Article;
import com.dcms.admin.dao.ArticleMapper;
import com.dcms.admin.service.IArticleService;
import com.dcms.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: baochao
 * @Date 2018/2/12 0012
 * @PROJECT_NAME vso
 */
@Service
public class ArticleServiceImpl implements IArticleService{

    @Autowired
    private ArticleMapper mapper;

    public int deleteByPrimaryKey(Integer articleId) {
        return mapper.deleteByPrimaryKey(articleId);
    }

    public int insertSelective(Article article) {
        return mapper.insertSelective(article);
    }

    public Article selectByPrimaryKey(Integer articleId) {
        return mapper.selectByPrimaryKey(articleId);
    }

    public int updateByPrimaryKeySelective(Article record) {
        return mapper.updateByPrimaryKeySelective(record);
    }

    /**
     * 根据条件查询所有的Article
     *
     * @param param 用于模糊查询Article
     * @return
     */
    public List<Article> selectAll(String param) {
        Map map =new HashMap(1);
        if (param!=null && "".equals(param)){
            map.put("param", StringUtil.appendPerCent(param));
        }
        return mapper.selectAll(map);
    }

    /**
     * 根据 articleIds 批量删除
     *
     * @param articleIds
     * @return
     */
    public int deleteByPrimaryKeyBatch(List<String> articleIds) {
        return mapper.deleteByPrimaryKeyBatch(articleIds);
    }


}
